clear all
dropbox
cd "Asymmetric Polarization"
set maxvar 32000

//Recode all three datasets
foreach d in GSS Pew Gallup {
run "analysis/Individual_dos/`d' Data Coding.do"	
}

//Combine datasets into one
use "data/individual/GSS_1972_2021_recode.dta", clear
append using "data/individual/Pew_2001_2021_recode.dta"
append using "data/individual/Gallup_1989_2021_recode.dta"

la var spend_env "Environmental Spending"
la var sci_con "Confidence in Scientific Community"
la var cc_when "CC is already happening"
la var cc_exagg "CC is Exaggerated"
la var cc_worry "CC Worry"
la var cc_threat "CC is a Major Threat"
la var cc_priority "CC is a Top Priority"


la var year "Period"
la var age "Age"
la var partyid3 "Party Affiliation"
la var cohort "Age Cohort, 5 yr. intervals"

recode race ///
	(1=1 "White") ///
	(2/4=0 "Not white") ///
	(else=.), ///
	gen(white) l(white)
la var white "White"
save "data/combined_GSS_PEW_Gallup.dta", replace

//Set labels for Graph Groups
loc l_env "Environmental Attitudes"
loc l_clim_belief "Climate Change Beliefs"
loc l_clim_att "Climate Change Attitudes"

//Set min and max for years in graph - making common x-axis in combined graphs
foreach y in ///
	spend_env sci_con ///
	cc_when cc_exagg ///
	cc_worry cc_threat cc_priority {
	qui sum year if `y'!=.
	loc xmin_`y'=r(min)
	loc xmax_`y'=r(max)	
}

//Set Predicted Value Label - Making y-label more clear
loc ylab_spend_env "Pr('Too Little')"
loc ylab_sci_con "Pr('A Great Deal')"
loc ylab_cc_when "Pr('Has Already Begun')"
loc ylab_cc_exagg "Pr('Generally Exaggerated')"
loc ylab_cc_worry "Pr('A Great Deal')"
loc ylab_cc_threat "Pr('Major Threat')"
loc ylab_cc_priority "Pr('Top Priority')"

//Set labels for each measure
loc lspend_env "Environmental Spending"
loc lsci_con "Confidence in Scientific Community"
loc lcc_when "CC is already happening"
loc lcc_exagg "CC is Exaggerated"
loc lcc_worry "CC Worry"
loc lcc_threat "CC is a Major Threat"
loc lcc_priority "CC is a Top Priority"

//Set labels for data source
loc data_spend_env "GSS" 
loc data_cc_when "Gallup GPSS"
loc data_cc_priority "Pew Top Priority"
loc data_cc_threat "Pew Major Threat"

//Set labels for Graph Groups
loc l_env "Environmental Attitudes"
loc l_clim_belief "Climate Change Beliefs"
loc l_clim_att "Climate Change Attitudes"

********Descriptive Statistics
//Create dummy variables for categorical variables
la def partyid3 ///
	1 "Republican" 2 "Independent" ///
	3 "Democrat", modify

la def education ///
	1 "Less than HS" 2 "HS Graduate" ///
	3 "Some College" 4 "College Graduate", modify
	
la def education2 ///
	1 "Less_HS" 2 "HS_Graduate" ///
	3 "Some_College" 4 "College_Graduate", modify
la val education education2
	
foreach recodevar in partyid3 education {
levelsof `recodevar'
foreach value in `r(levels)' {
	gen `: label (`recodevar') `value'' = `recodevar' == `value'
	replace `: label (`recodevar') `value''=. if `recodevar'==.
	la def `: label (`recodevar') `value'' 0 "not `: label (`recodevar') `value''" ///
	1 "`: label (`recodevar') `value''", modify
	la val `: label (`recodevar') `value'' `: label (`recodevar') `value''				
	la var `: label (`recodevar') `value'' "`: label (`recodevar') `value''"
	}
}
la val education education

la var Less_HS "Less than HS"
la var HS_Graduate "HS Graduate"
la var Some_College "Some College"
la var College_Graduate "College Graduate"

//GSS
*Cumulative
qui regress ///
	spend_env ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate ///
	Some_College College_Graduate white	

preserve
qui estpost tabstat ///
	spend_env sci_con ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), ///
	statistics(mean sd) columns(statistics) listwise
est sto desc_all_gss
restore

*By Year
preserve	
qui estpost tabstat ///
	spend_env sci_con ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample)&year<=1991, by(year) ///
	statistics(mean sd) columns(statistics) listwise nototal

esttab using "analysis/tables/GSS_year1.tex", ///
	main(mean 2) aux(sd 2) nostar unstack ///
	nonote nomtitle nonumber noobs ///
	label replace ///
	title(\textbf{GSS Descriptive Statistics 1973-1991}. Mean and standard deviation of 	GSS data (in parentheses) per survey year from 1973-1991.\label{tab:gssdesc1})
restore
	
preserve	
qui estpost tabstat ///
	spend_env sci_con ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample)&year>1991, by(year) ///
	statistics(mean sd) columns(statistics) listwise nototal

esttab using "analysis/tables/GSS_year2.tex", ///
	main(mean 2) aux(sd 2) nostar unstack ///
	nonote nomtitle nonumber noobs ///
	label replace ///
	title(\textbf{GSS Descriptive Statistics 1993-2021}. Mean and standard deviation of 	GSS data (in parentheses) per survey year from 1993-2021.\label{tab:gssdesc2})
restore	

//GPSS
*Cumulative
qui regress ///
	cc_worry ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate ///
	Some_College College_Graduate white 

preserve
qui estpost tabstat ///
	cc_worry cc_when cc_exagg ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), ///
	statistics(mean sd) columns(statistics) listwise
est sto desc_all_gpss
restore

*By Year
preserve	
qui estpost tabstat ///
	cc_worry cc_when cc_exagg ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), by(year) ///
	statistics(mean sd) columns(statistics) nototal

esttab using "analysis/tables/GPSS_year.tex", ///
	main(mean 2) aux(sd 2) nostar unstack ///
	noobs nonote nomtitle nonumber ///
	label replace ///
	title(\textbf{Gallup GPSS Descriptive Statistics 1989-2022}. Mean and standard deviation of GPSS data (in parentheses) per survey year from 1989-2022.\label{tab:gpssdesc})
restore

//Pew Priority
*Cumulative
qui regress ///
	cc_priority ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate ///
	Some_College College_Graduate white 

preserve
qui estpost tabstat ///
	cc_priority ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), ///
	statistics(mean sd) columns(statistics) listwise
est sto desc_all_pew_priority
restore

*By Year
preserve	
qui estpost tabstat ///
	cc_priority ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), by(year) ///
	statistics(mean sd) columns(statistics) listwise nototal

esttab using "analysis/tables/Pew_Priority_year.tex", ///
	main(mean 2) aux(sd 2) nostar unstack ///
	noobs nonote nomtitle nonumber ///
	label replace ///
	title(\textbf{Pew Climate Change as Top Priority Descriptive Statistics 2001-2020}. Mean and standard deviation of Pew Climate Change as Top Priority data (in parentheses) per survey year from 2001-2020.\label{tab:pewpriodesc})
restore

//Pew Threat
*Cumulative
qui regress ///
	cc_threat ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate ///
	Some_College College_Graduate white 

preserve
qui estpost tabstat ///
	cc_threat ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), ///
	statistics(mean sd) columns(statistics) listwise
est sto desc_all_pew_threat
restore

*By Year
preserve	
qui estpost tabstat ///
	cc_threat ///
	Republican Independent Democrat ///
	age female ///
	Less_HS HS_Graduate Some_College College_Graduate white ///
	if e(sample), by(year) ///
	statistics(mean sd) columns(statistics) listwise nototal

esttab using "analysis/tables/Pew_Threat_year.tex", ///
	main(mean 2) aux(sd 2) nostar unstack ///
	noobs nonote nomtitle nonumber ///
	label replace ///
	title(\textbf{Pew Climate Change as Major Threat Descriptive Statistics 2009-2020}. Mean and standard deviation of Pew Climate Change as Major Threat data (in parentheses) per survey year from 2009-2020.\label{tab:pewthreatdesc})
restore

//Combine cumulative descriptives
esttab ///
	desc_all_gss ///
	desc_all_gpss ///
	desc_all_pew_priority ///
	desc_all_pew_threat ///
	using "analysis/tables/desc_all.tex", ///
	main(mean 2) aux(sd 2) nostar unstack ///
	nonote nonumber ///
	mtitles( ///
		"GSS" "GPSS" ///
		"Pew Priority" "Pew Threat") ///
	order( ///
		spend_env sci_con ///
		cc_worry cc_when cc_exagg ///
		cc_priority cc_threat) ///
	title(\textbf{Cumulative Descriptive Statistics}. Cumulative mean and standard deviation (in parenthese) by each historical dataset.\label{tab:desc_all}) ///
	label replace

//Dependent Variables over time 
preserve

collapse ///
	spend_env sci_con ///
	cc_when cc_exagg ///
	cc_worry cc_threat cc_priority, ///
	by(year)

graph twoway ///
	(connected spend_env year if year>=`xmin_spend_env', ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow)) ///
	(connected sci_con year if year>=`xmin_sci_con', ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow)), ///
	title("`l_env'", ///
	c(black) size(med)) ///
	 legend(order( ///
		1 "`lspend_env'" ///
		2 "`lsci_con'") row(1) pos(6)) ///
	xlabel(`xmin_spend_env'(2)`xmax_spend_env', ///
		val angle(90) labs(vsmall) glc(white) format(%4.0f)) ///
	ylabel(0.2(0.1)0.8, glc(white) format(%3.2f) ///
	 labs(vsmall)) ///
	ytitle("Proportion of responses", s(small)) ///
	xtitle("", s(medium) c(black)) ///
	scheme(plotplain) name(period_env_att, replace) nodraw
	
*Climate beliefs
graph twoway ///
	(connected cc_worry year if year>=`xmin_cc_worry', ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow)) ///
	(connected cc_when year if year>=`xmin_cc_when ', ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow)) ///
	(connected cc_exagg year if year>=`xmin_cc_exagg', ///
	lc(edkblue) lp(solid) ///
	mc(edkblue) ms(square_hollow)), ///
	title("`l_clim_belief'", ///
	c(black) size(med)) ///
	 legend(order( ///
		1 "`lcc_worry'" ///		
		2 "`lcc_when'" ///
		3 "`lcc_exagg'") row(2) pos(6)) ///
	xlabel(`xmin_cc_worry'(2)`xmax_cc_worry', ///
		val angle(90) labs(vsmall) glc(white) format(%4.0f)) ///
	ylabel(0.2(0.1)0.8, glc(white) format(%3.2f) ///
		labs(vsmall)) ///
	ytitle("Proportion of responses", s(small)) ///
	xtitle("", s(medium) c(black)) ///
	scheme(plotplain) name(period_clim_belief, replace) nodraw
	
*Climate Attitudes
graph twoway ///
	(connected cc_priority year if year>=`xmin_cc_priority', ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow)) ///
	(connected cc_threat year if year>=`xmin_cc_threat', ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow)), ///
	title("`l_clim_att'", ///
	c(black) size(med)) ///
	 legend(order( ///
		1 "`lcc_threat'" ///
		2 "`lcc_priority'") row(1) pos(6)) ///
	xlabel(`xmin_cc_priority'(2)`xmax_cc_priority', ///
		val angle(90) labs(vsmall) glc(white) format(%4.0f)) ///
	ylabel(0.2(0.1)0.8, glc(white) format(%3.2f) ///
		labs(vsmall)) ///
	ytitle("Proportion of responses", s(small)) ///
	xtitle("", s(medium) c(black)) ///
	scheme(plotplain) name(period_clim_att, replace) nodraw
restore

*Combine
gr combine ///
	period_env_att ///
	period_clim_belief ///
	period_clim_att, ///
	ti("") ///
	col(1) ///
	ysize(10) ///
	name(period, replace)

gr export "analysis/graphs/period.pdf", ///
	as(pdf) name("period") replace

gr export "analysis/graphs/period.eps", ///
	as(eps) name("period") replace	

//Party Affilation Over Time and By Dataset
foreach y in ///
	spend_env ///
	cc_when cc_priority  ///
	cc_threat {
	qui sum year if `y'!=.
	loc xmin_`y'=r(min)
	loc xmax_`y'=r(max)

preserve
collapse ///
	Republican Independent Democrat if `y'!=., ///
	by(year)
	
graph twoway ///
	(line Democrat year, ///
		lc(edkblue) lp(solid) mc(edkblue) ms(square)) ///
	(line Independent year, ///
		lc(forest_green) lp(shortdash_dot) mc(forest_green) ms(circle)) ///
	(line Republican year, ///
		lc(maroon) lp(shortdash) mc(maroon) ms(triangle)), ///
	title("`data_`y''", c(black) size(medium)) ///
	ytitle("Proportion of Respondents", size(small)) ///
	xtitle("", size(medsmall)) ///
	ylabel(0(0.1)0.6, gmax format(%2.1f) glc(white)) ///
	xlabel(`xmin_`y''(2)`xmax_`y'', ///
		val angle(90) labs(vsmall) glc(white) format(%4.0f)) ///
	graphregion(color(white) lcolor(white)) ///
	legend(cols(3) region(lcolor(white)) ///
	label(1 "Democrat") ///
	label(2 "Independent") ///
	label(3 "Republican") ///
	pos(6)) ///
	scheme(plotplain) ///
	name(party_`y', replace) nodraw
restore
}

grc1leg ///
	party_spend_env ///
	party_cc_when ///
	party_cc_priority  ///
	party_cc_threat, ///
	ti("") ///
	col(2) ///
	name(partyid_time, replace)

gr export "analysis/graphs/partyid_time.pdf", ///
	as(pdf) name("partyid_time") replace

gr export "analysis/graphs/partyid_time.eps", ///
	as(eps) name("partyid_time") replace	
/*	
//Calculate CCREM Models (note can \* after data is run and saved)
foreach y in ///
	spend_env sci_con ///
	cc_priority cc_threat ///
	cc_worry cc_when cc_exagg {
xtmelogit `y' b3.partyid3 c.age##c.age female ///
	b4.education b1.white ///
	|| _all:R.year || partyid3:R.year || cohort:, var
	
est sto `y'
estsave, gen(CCREM_`y')
	}
	
save "analysis/CCREM_Results/CCREM_Combined.dta", replace	
*/

//Create CCREM Regression Table
use "analysis/CCREM_Results/CCREM_Combined.dta", clear

foreach y in ///
	spend_env sci_con ///
	cc_when cc_exagg ///
	cc_worry cc_threat cc_priority {
estsave, from(CCREM_`y') 
est sto `y'
qui levelsof year if `y'!=.
estadd scalar nyr=r(r)
	}

esttab spend_env sci_con ///
	cc_priority cc_threat ///
	cc_worry cc_when cc_exagg ///
	using "analysis/tables/ccrem.tex", ///
	 replace mlabel(none) label se(2) b(2) ///
	 stats(N nyr, ///
		labels("N" "Number of Years") ///
		fmt(0 0)) ///
	 nobaselevels nogap ///
	 nonumber star(* 0.05 ** 0.01) ///
	transform(ln*: exp(2*@) 2*exp(2*@))   ///
	eqlabels("" "var(Year)" "var(Year:Party ID)" "var(Cohort)", none) ///
	title(CCREM Table\label{tab:ccrem}) ///
	prehead(\begin{landscape}\begin{table}[h!]\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\caption{\textbf{CCREM Table.} Cross-classified random effects logistic regression of environmental and climate change attitudes on party affiliation.}\label{tab:ccrem}\begin{tabular}{p{\dimexpr 0.14\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}p{\dimexpr 0.13\linewidth-2\tabcolsep}}\hline\hline&Environmental Spending&Confidence in Scientific Community&Climate Change is a Top Priority&Climate Change is a Major Threat&Climate Change Worry&When Climate Change Will Happen&Seriousness of Climate Change\\) ///
	postfoot(\hline\hline\multicolumn{8}{l}{\footnotesize Standard errors in parentheses, \sym{*} \(p<0.05\), \sym{**} \(p<0.01\)}\\\end{tabular}\end{table}\end{landscape})

/*
//Calculate Predictions (note can \* after data is run and saved)
use "analysis/CCREM_Results/CCREM_Combined.dta", clear
gen dv=" "
foreach y in ///
	spend_env sci_con ///
	cc_priority cc_threat ///
	cc_worry cc_when cc_exagg {
estsave, from(CCREM_`y')

matrix b = e(b)
local re1_col = colnumb(b, "lns1_1_1:_cons")
local re2_col = colnumb(b, "lns2_1_1:_cons")
local re3_col = colnumb(b, "lns3_1_1:_cons")
local re1_var = exp(b[1, `re1_col'])^2
local re2_var = exp(b[1, `re2_col'])^2
local re3_var = exp(b[1, `re3_col'])^2
di `re1_var', `re2_var', `re3_var'
estadd scalar re1_var=`re1_var'

foreach x of numlist 1 2 3 {
// First get the predictions for the fixed part
qui predict out_`y'_`x' if partyid3==`x' & e(sample), xb
//Then predict the random effects
qui predict per_`y'_`x' pol_`y'_`x' coh_`y'_`x' if partyid3==`x' & e(sample), reffects

//Then get the standard errors of the random parts
qui predict perses_`y'_`x' polses_`y'_`x' cohses_`y'_`x' if partyid3==`x' & e(sample), reses

//Then get the mean of the period and cohort effects (since we want to average over all periods)
qui sum coh_`y'_`x'
local mcoh_`y'_`x' = r(mean)
qui sum per_`y'_`x'
local mper_`y'_`x' = r(mean)
di `mcoh_`y'_`x''
di `mper_`y'_`x''

//Then calculate predicted probabilities for party with cohort, period and all others held at means
gen muPol_`y'_`x' = 1 /(1+exp(-1*(out_`y'_`x' + `mper_`y'_`x'' + `mcoh_`y'_`x'' + pol_`y'_`x')))

//Then calculate the 95% confidence intervals for the period effects from the standard errors
gen polci_low_`y'_`x' = -1.96*polses_`y'_`x'
gen polci_hi_`y'_`x' = 1.96*polses_`y'_`x'

//Then calculate predicted probabilities for upper and lower bounds of the confidence intervals
gen muPol_low_`y'_`x' = 1 /(1+exp(-1*(out_`y'_`x' + `mper_`y'_`x'' + `mcoh_`y'_`x'' + pol_`y'_`x' + polci_low_`y'_`x')))
gen muPol_hi_`y'_`x' = 1 /(1+exp(-1*(out_`y'_`x' + `mper_`y'_`x'' + `mcoh_`y'_`x'' + pol_`y'_`x' + polci_hi_`y'_`x')))
}

//Make Period PPs
qui predict xb_`y' if e(sample), xb 
qui predict re_`y'_* if e(sample), reffects
qui predict res_`y'_* if e(sample), reses
gen periodre_`y'=invlogit(re_`y'_1) if e(sample)
gen perci_`y' = 1.96*res_`y'_1 if e(sample)
gen per_hi_`y' = periodre_`y' + perci_`y'
gen per_low_`y' = periodre_`y'- perci_`y'

//Make Cohort PPs
gen cohortre_`y'=invlogit(re_`y'_3) if e(sample)
gen cohci_`y' = 1.96*res_`y'_3 if e(sample)
gen coh_hi_`y' = cohortre_`y' + cohci_`y'
gen coh_low_`y' = cohortre_`y' - cohci_`y'


replace dv="`y'" if xb_`y'!=.
}

rename dv dv_str
encode dv_str, generate(dv)

save "analysis/CCREM_Results/CCREM_PP.dta", replace
*/

**********CCREM Graphs***************
use "analysis/CCREM_Results/CCREM_PP.dta", clear

//Effects by Party
foreach y in ///
	spend_env sci_con ///
	cc_priority cc_threat ///
	cc_worry cc_when cc_exagg {
preserve

qui sum year if `y'!=.
loc yr_min=r(min)
keep if year>=`yr_min'

collapse ///
	muPol_`y'_1 muPol_low_`y'_1 muPol_hi_`y'_1 ///
	muPol_`y'_2 muPol_low_`y'_2 muPol_hi_`y'_2 ///
	muPol_`y'_3 muPol_low_`y'_3 muPol_hi_`y'_3 ///
	`y' (firstnm) dv, ///
	by(year)
	label var `y' `"`l`y''"' 
		 
graph twoway ///
	rline  muPol_low_`y'_1 muPol_hi_`y'_1 year, ///
	lstyle(ci) lwidth(.2) lcolor(maroon%30) ///
	lpattern(shortdash)  || ///
	connected muPol_`y'_1 year, ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow) || ///
	rline muPol_low_`y'_2 muPol_hi_`y'_2 year, ///
	lstyle(ci) lwidth(.2) lcolor(forest_green%30) ///
	lpattern(shortdash) || ///
	connected muPol_`y'_2 year, ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow) || ///
	rline muPol_low_`y'_3 muPol_hi_`y'_3 year, ///
	lstyle(ci) lwidth(.2) lcolor(edkblue%30) ///
	lpattern(shortdash) || ///
	connected muPol_`y'_3 year, ///
	lc(edkblue) lp(solid) mc(edkblue) ms(square_hollow) ///
	title(`l`y'', c(black) size(medium)) ///
	ytitle("`ylab_`y''", size(small)) ///
	xtitle("", size(small)) ///
	ylabel(0.0(0.1)0.9, gmax format(%3.2f) labs(vsmall) glc(white)) ///
	xlabel(`xmin_`y''(2)`xmax_`y'', gmax format(%2.0f) angle(90) ///
	labsize(vsmall) labcolor(black) glc(white)) ///
	graphregion(color(white) lcolor(white)) ///
	legend(cols(3) region(lcolor(white)) ///
	order(6 "Democrat" 4 "Independent" 2 "Republican") ///
	pos(6)) ///
	scheme(plotplain) name(party_`y',replace) nodraw
	restore
	 }

grc1leg ///
	party_spend_env ///
	party_sci_con, ///
	ti(`l_env') ///
	row(1) ///
	name(party_env, replace)

gr export "analysis/graphs/party_env.pdf", ///
	as(pdf) name("party_env") replace

gr export "analysis/graphs/party_env.eps", ///
	as(eps) name("party_env") replace
	
grc1leg ///
	party_cc_worry ///
	party_cc_when ///
	party_cc_exagg, ///
	ti(`l_clim_belief') ///
	row(1) ///
	name(party_clim_belief, replace)

gr export "analysis/graphs/party_clim_belief.pdf", ///
	as(pdf) name("party_clim_belief") replace

gr export "analysis/graphs/party_clim_belief.eps", ///
	as(eps) name("party_clim_belief") replace

grc1leg ///
	party_cc_priority ///
	party_cc_threat, ///
	ti(`l_clim_att') ///
	row(1) ///
	name(party_clim_att, replace) 

gr export "analysis/graphs/party_clim_att.pdf", ///
	as(pdf) name("party_clim_att") replace

gr export "analysis/graphs/party_clim_att.eps", ///
	as(eps) name("party_clim_att") replace

//Cohort
*Environmental Attitudes
preserve

foreach y in ///
	spend_env sci_con ///
	cc_priority cc_threat ///
	cc_worry cc_when cc_exagg {
	local l`y' : var lab `y'	
	} 

collapse ///
	cohortre_spend_env cohortre_sci_con ///
	cohortre_cc_when cohortre_cc_exagg ///
	cohortre_cc_worry cohortre_cc_threat cohortre_cc_priority ///
	, by(cohort)

graph twoway ///
	(connected cohortre_spend_env cohort, ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow)) ///
	(connected cohortre_sci_con cohort, ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow)), ///
	title("`l_env'", ///
	c(black) size(med)) ///
	 legend(order( ///
		1 "`lspend_env'" ///
		2 "`lsci_con'") row(1) pos(6)) ///
	xlabel(1(1)20, val angle(90) labs(vsmall) glc(white)) ///
	ylabel(0.4(0.05)0.6, glc(white) format(%3.2f) labs(vsmall)) ///
	ytitle("") ///
	xtitle("", s(medium) c(black)) ///
	scheme(plotplain) name(cohort_env, replace) nodraw

*Climate beliefs
graph twoway ///
	(connected cohortre_cc_worry cohort if cohort>=5, ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow)) ///
	(connected cohortre_cc_when cohort, ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow)) ///
	(connected cohortre_cc_exagg cohort, ///
	lc(edkblue) lp(solid) ///
	mc(edkblue) ms(square_hollow)), ///
	title("`l_clim_belief'", ///
	c(black) size(med)) ///
	 legend(order( ///
		1 "`lcc_worry'" ///		
		2 "`lcc_when'" ///
		3 "`lcc_exagg'") row(2) pos(6)) ///
	xlabel(1(1)20, val angle(90) labs(vsmall) glc(white)) ///
	ylabel(0.4(0.05)0.6, glc(white) format(%3.2f) labs(vsmall)) ///
	ytitle("") ///
	xtitle("", s(medium) c(black)) ///
	scheme(plotplain) name(cohort_clim_belief, replace) nodraw
	
*Climate Attitudes
graph twoway ///
	(connected cohortre_cc_worry cohort if cohort>=5, ///
	lc(maroon) lp(shortdash) ///
	mc(maroon) ms(triangle_hollow)) ///
	(connected cohortre_cc_threat cohort, ///
	lc(forest_green) lp(shortdash_dot) ///
	mc(forest_green) ms(circle_hollow)) ///
	(connected cohortre_cc_priority cohort, ///
	lc(edkblue) lp(solid) ///
	mc(edkblue) ms(square_hollow)), ///
	title("`l_clim_att'", ///
	c(black) size(med)) ///
	 legend(order( ///
		1 "`lcc_threat'" ///
		2 "`lcc_priority'") row(1) pos(6)) ///
	xlabel(1(1)20, val angle(90) labs(vsmall) glc(white)) ///
	ylabel(0.4(0.05)0.6, glc(white) format(%3.2f) labs(vsmall)) ///
	ytitle("") ///
	xtitle("", s(medium) c(black)) ///
	scheme(plotplain) name(cohort_clim_att, replace) nodraw
restore

*Combine
gr combine ///
	cohort_env ///
	cohort_clim_belief ///
	cohort_clim_att, ///
	ti("") ///
	col(1) ///
	ysize(10) ///
	name(cohort, replace)

gr export "analysis/graphs/cohort.pdf", ///
	as(pdf) name("cohort") replace

gr export "analysis/graphs/cohort.eps", ///
	as(eps) name("cohort") replace	
